package pls_parser;

import java.util.ArrayList;
import java.util.List;

import network.NetworkCell;
import network.NetworkMap;
import utils.Logger;
import analysis.PlsEvent;
import area.Placemark;

public class RouteAnalyzer extends BufferAnalyzer {

	List<Placemark> ps;
	int cont = 0;
	
	public RouteAnalyzer(Placemark p1, Placemark p2) {
		ps = new ArrayList<Placemark>();
		ps.add(p1);
		ps.add(p2);
	}
	
	public void analyze(String line) {
		
		String[] fields = line.split("\t");
		String username = fields[0];
		String imsi = fields[1];
		String celllac = fields[2];
		String timestamp = fields[3];
		
		
		PlsEvent x = new PlsEvent(username,imsi,Long.parseLong(celllac),timestamp);
		NetworkMap nm = NetworkMap.getInstance();
		NetworkCell nc = nm.get(x.getCellac());
		
		
		for(int i=0; i<ps.size();i++)
		if(ps.get(i).contains(celllac)) 
			cont++;
	}

	
	public void finalize() {
		System.out.println(cont);
		
	}
	
	public static void main(String[] args) throws Exception {
		//UsersAroundAnEvent ba = new UsersAroundAnEvent(CityEvent.GAME_SILVIO_PIOLA_11_3_2012);
		RouteAnalyzer ba = new RouteAnalyzer(Placemark.STADIO_SILVIO_PIOLA_NO, Placemark.JUVE_STADIUM_TO);
		PLSParser.parse(ba);
		ba.finalize();
		Logger.logln("Done");
	}
	
	
	

}
